package admin

import (
	"gitcode.com/G-YT/ANN/server/global"
	"gitcode.com/G-YT/ANN/server/model/common/response"
	"gitcode.com/G-YT/ANN/server/service"
	"gitcode.com/G-YT/ANN/server/utils"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

type DataAnalysisApi struct {
}

var SystemUserService = service.ServiceGroupApp.SystemServiceGroup.UserService

// GetServiceCenterMapData 獲取服务中心地图数据【超管】
// @Router /dataAnalysis/getServiceCenterMapData [get]
func (d *DataAnalysisApi) GetServiceCenterMapData(c *gin.Context) {
	if info, err := SystemUserService.GetServiceCenterMapData(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(info, "獲取成功", c)
	}
}

// GetStationsMapDataByHm 獲取服务站地图数据【服务中心】
// @Router /dataAnalysis/getStationsMapDataByHm [get]
func (d *DataAnalysisApi) GetStationsMapDataByHm(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if info, err := SystemUserService.GetStationsMapDataByHm(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(info, "獲取成功", c)
	}
}

// GetStationsMapDataByUser 獲取服务站地图数据【服务中心】
// @Router /dataAnalysis/getStationsMapDataByUser [get]
func (d *DataAnalysisApi) GetStationsMapDataByUser(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if info, err := SystemUserService.GetStationsMapDataByUser(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(info, "獲取成功", c)
	}
}

// GetServiceStationMapData 獲取服务中心地图数据【超管】
// @Router /dataAnalysis/getServiceStationMapData [get]
func (d *DataAnalysisApi) GetServiceStationMapData(c *gin.Context) {
	if info, err := SystemUserService.GetServiceStationMapData(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(info, "獲取成功", c)
	}
}

// GetServiceStationRank 獲取服务中心下服务站数量排名【超管】
// @Router /dataAnalysis/getServiceStationRank [get]
func (d *DataAnalysisApi) GetServiceStationRank(c *gin.Context) {
	if list, err := SystemUserService.GetServiceStationRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetHealthManagerRank 獲取服务中心下健管师数量排名【超管】
// @Router /dataAnalysis/getHealthManagerRank [get]
func (d *DataAnalysisApi) GetHealthManagerRank(c *gin.Context) {
	if list, err := SystemUserService.GetHealthManagerRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationsRankByHmNum 獲取服务站排名根据健管师数量【服务中心】
// @Router /dataAnalysis/getStationsRankByHmNum [get]
func (d *DataAnalysisApi) GetStationsRankByHmNum(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if list, err := SystemUserService.GetStationsRankByHmNum(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetUserRank 獲取服务中心下用户数量排名【超管】
// @Router /dataAnalysis/getUserRank [get]
func (d *DataAnalysisApi) GetUserRank(c *gin.Context) {
	if list, err := SystemUserService.GetUserRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetServiceCenterDiseaseList 獲取服务中心主病症列表【超管】
// @Router /dataAnalysis/getServiceCenterDiseaseList [get]
func (d *DataAnalysisApi) GetServiceCenterDiseaseList(c *gin.Context) {
	if list, err := SystemUserService.GetServiceCenterDiseaseList(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetCompletePlanUserRank 獲取服务站完成方案用户数量排名【超管】
// @Router /dataAnalysis/getScCompletePlanUserRank [get]
func (d *DataAnalysisApi) GetCompletePlanUserRank(c *gin.Context) {
	if list, err := SystemUserService.GetCompletePlanUserRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationsRankByCpuNum 獲取服务中心完成方案用户排行【服务中心】
// @Router /dataAnalysis/getStationsRankByCpuNum [get]
func (d *DataAnalysisApi) GetStationsRankByCpuNum(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if list, err := SystemUserService.GetStationsRankByCpuNum(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationHealthManagerRank 獲取服务站健管师数量排名【超管】
// @Router /dataAnalysis/getStationHealthManagerRank [get]
func (d *DataAnalysisApi) GetStationHealthManagerRank(c *gin.Context) {
	if list, err := SystemUserService.GetStationHealthManagerRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationUserRank 獲取服务站用户数量排名【超管】
// @Router /dataAnalysis/getStationUserRank [get]
func (d *DataAnalysisApi) GetStationUserRank(c *gin.Context) {
	if list, err := SystemUserService.GetStationUserRank(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationRankByUserNum 獲取服务站排名根据用户数量【服务中心】
// @Router /dataAnalysis/getStationRankByUserNum [get]
func (d *DataAnalysisApi) GetStationRankByUserNum(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if list, err := SystemUserService.GetStationRankByUserNum(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetStationDiseaseList 獲取服务站主病症列表【超管】
// @Router /dataAnalysis/getStationDiseaseList [get]
func (d *DataAnalysisApi) GetStationDiseaseList(c *gin.Context) {
	if list, err := SystemUserService.GetStationDiseaseList(); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}

// GetCentreDiseaseList 獲取服务中心主病症列表【服务中心】
// @Router /dataAnalysis/getCentreDiseaseList [get]
func (d *DataAnalysisApi) GetCentreDiseaseList(c *gin.Context) {
	CentreID := utils.GetUserID(c)
	if list, err := SystemUserService.GetCentreDiseaseList(CentreID); err != nil {
		global.GVA_LOG.Error("獲取失敗!", zap.Error(err))
		response.FailWithMessage("獲取失敗", c)
	} else {
		response.OkWithDetailed(list, "獲取成功", c)
	}
}
